package com.wl.computerservice2.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wangl
 * @desc
 * @date:2017/6/218:30
 * @Copyright (c) 2017, DaChen All Rights Reserved.
 */
@RestController
public class Computerservice2Controller {

    @Autowired
    DiscoveryClient client;

    @RequestMapping(value = "/add" ,method = RequestMethod.GET)
    public int add(Integer a, Integer b){
        List<ServiceInstance> instance = client.getInstances("compute-service");
        int r = a + b;
        System.out.println("/add, host = "+ instance.get(0).getHost() + ", service_id = "+instance.get(0).getServiceId());
        return r;
    }
}
